<?php //pr($solds); ?>
<?php if(!empty($solds)): ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="sold_table" class="tablesorter">
	<thead>
		<tr>
			<th style="width:auto;"><input type="checkbox" id="select_all" /></th><th style="width:auto;">&nbsp;</th>
			<th style="width:auto;">(Item #)Title</th><th style="width:auto;">Buyer ID</th>
			<th style="width:auto;">Qty</th><th style="width:auto;">Price</th>
			<th style="height:35px;width:auto;">Total Price</th>
			<th style="height:35px;width:auto;">Sale Date</th>
			<th style="width:auto;">Order ID</th><th style="width:auto;">Tracking #</th><th style="width:auto;">Carrier</th><th style="width:auto;">Action</th>
		</tr>
	</thead>
	<tbody>
	<?php $i=0;foreach($solds as $sold):
		$class = 'even';
		if ($i++ % 2 == 0)
			$class = 'odd';
	?>
	<tr id="row_<?php echo $sold['Order']['id'];?>" class="<?php echo $class;?>">
		<td><input type="checkbox" id="sold_id" value="<?php echo $sold['Order']['id']; ?>" /></td>
		<td><img src="<?php echo Configure::read('base_url');?>img/uploads/<?php echo $sold['Product']['products_thumbnailImage'];?>" width="50" /></td>
		<td>
			<a href="<?php echo Configure::read('base_url');?>products/details/<?php echo $sold['Product']['id'];?>" target="_blank" title="<?php echo $sold['Product']['products_title'];?>">(<?php echo $sold['Product']['id'];?>) <?php echo $sold['Product']['products_title'];?></a>
		</td>
		<td><?php echo $sold['User']['first_name']." ".$sold['User']['last_name'];?></td>
		<td><?php echo $sold['Order']['quantity'];?></td>
		<td>US $<?php echo $sold['Order']['product_cost'];?></td>
		<td>US $<?php echo ($sold['Order']['product_cost']*$sold['Order']['quantity']);?></td>
		<td><?php echo date("m-d-Y",strtotime($sold['Order']['add_date']));?></td>
		<td><?php echo $sold['Order']['id'];?></td>
		<td><?php echo $sold['Order']['transaction_id'];?></td>
		<td>USPS</td>
		<td>
			<a href="javascript:void(0);">Sell Similar</a><br />
			<a href="javascript:void(0);" controller="products" action="add_tracking" ElmID="<?php echo $sold['Order']['id']; ?>" onclick="showPop(this)" title="Add Tracking">Add Tracking</a><br />
			<a href="javascript:void(0);" controller="products" action="contact_buyer" title="Contact Buyer" onclick="showPop(this)"  ElmID="<?php echo $sold['Product']['id']; ?>" onclick='showPop(this)'>Contact Buyer</a>
                        <a href="javascript:void(0);" controller="products" action="create_dispute" title="create_dispute"
               ElmID="<?php echo $sold['Product']['id']; ?>" onclick='showPop(this)'>
            <input type="button" value="dispute" /></a>
		</td>
		</tr>
		<?php
        $comments = $this->requestAction('/products/getnote/'.$sold['Product']['id'].'/'.$session->read('Auth.User.id').'/'.'3');

        if (!empty($comments)) {
        ?>
		<tr class="fullrow<?php echo $sold['Product']['id']; ?>" >
            <td colspan="12" id="disnote<?php echo $sold['Product']['id']; ?>" style="background: none repeat scroll 0pt 0pt BlanchedAlmond;text-align: left;">
			<?php
			foreach($comments as $comment) {
				echo '<b>'.'My Note'.' [ '.date('m-d-Y',  strtotime($comment['Note']['created'])).' ] : </b> '.$comment['Note']['note'];echo"<br/>";
			}
		?>
		</td></tr>
		<?php
        }
        ?>
		<?php endforeach;?>
	</tbody>
</table>



<?php else:?>
<br /><br />
<h2>Your search terms returns no result.</h2>
<br /><br /><br />
<?php endif;?>
<div class="paging">
    <?php
		echo $this->Paginator->prev('<< ' . __('previous', true), array(), null, array('class'=>'disabled'));?> |
	<?php echo $this->Paginator->numbers();?>
		|
	<?php echo $this->Paginator->next(__('next', true) . ' >>', array(), null, array('class' => 'disabled'));?>
</div>
